Bugfix/ogc 3406 surcharges or discounts zeros invoice - #2650
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted filessee 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Keeps the price fallback in `CustomReservation.invoice_item` from turning a stored 0 into None (which would trip the `price_per_item`/`price_per_hour` asserts and 500 on refresh) by only overriding when a positive price is recovered. Makes the org `Refresh reservation invoices zeroed by the pricing backfill` task explicitly require the reservation `Backfill reservation prices from invoice lines` task, so the refresh always runs after the data is repaired regardless of module ordering. Adds tests covering the refresh task and the full backfill-from-allocation to refresh recovery chain. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D4Jcf1cSmRS3pc9suqpYMc
| ), | ||
| 'price_per_item', | ||
| COALESCE( | ||
| res.content->'price_per_reservation', |
There was a problem hiding this comment.
the fallback case price lives on the resource content under price_per_reservation
| data->>'pricing_method' = 'per_item' | ||
| OR data->>'pricing_method' = 'per_hour' |
There was a problem hiding this comment.
those were wrong
|
I also found a few schemas that have reservations that had no pricing stored. risch: 11417 - per_item Tageskarte, 0 -> 40 there might be more... still testing |
|
Note: We decided to log all touched entries in order to keep track of the applied changes |
|
@Daverball I am not sure how it should be: currently a |
This can happen because of how our field dependencies work. If you switch from It's harmless for that to be propagated to the reservation, since as soon as the method is |
|
I attached a log to the ticket showing that many reservations are being changed with this upgrade |
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013jTHeEgh3qDGixrqK36HkV
|
Since Luckily it's not very harmful for the pricing information to be incorrect for a little while, since invoices are only refreshed on-demand. |
bc17a0f to
0d726b4
Compare
Reservation: Fix pricing snapshot migration that zeroed invoices
The
Store pricing settings on reservationsmigration zeroed the stored price of many reservations, which maderefresh_invoice_items(triggered e.g. by adding a surcharge/discount) wipe the invoice line and drop the payment (OGC-3406).Re-run the corrected migration under a new name so it executes again on already-upgraded databases, fixing three bugs that caused the zeroing:
pricing_methodconstants (price_per_item/price_per_hourinstead ofper_item/per_hour),resource = mirror_ofguard was mis-parenthesised (AND bound tighter than the following ORs), andcontent->'price_per_item', but the resource stores that value underprice_per_reservation.Add an org upgrade task to recompute invoice lines and payments that a post-rollout refresh had already zeroed. Scoped to reservation invoices modified on or after the backfill rollout (2026-08-18) that are tied to a paying reservation — a per_item/per_hour allocation, or a per_item resource and refreshed only when safe (manual, still-open payment).
TYPE: Bugfix
LINK: ogc-3406